<?php

/**
 * 后台锁定屏幕Controller
 */
namespace Files\Controller;
use Common\Controller\AdminbaseController;

class LockScreenController extends AdminbaseController
{

	protected $authLoginWhiteList=array(
		'Files.LockScreen.unLock'
	);
	public function _initialize()
	{
		parent::_initialize();
	}
	// 文件管理首页界面
	public function index(){
//		session("ADMIN_LOCKED_ID",null);
		//获取当前登陆人的信息，然后注销登陆
		$admin_id=sp_get_current_admin_id();
//		var_dump($admin_id);
		empty($admin_id) && $admin_id=session("ADMIN_LOCKED_ID");
		session("ADMIN_LOCKED_ID",$admin_id);
		session('ADMIN_ID',null);
		$this->display("index");
	}

	public function unLock(){
		$pwd=I("post.pwd/s","");
		$admin_id=session("ADMIN_LOCKED_ID");
		//var_dump($admin_id);
		//empty($pwd) && $this->redirect(__ROOT__."/admin/public/login");
		//empty($admin_id) && $this->redirect(__ROOT__."/admin/public/login");
		$passwd=M("Users")->where(array('id'=>$admin_id))->find();


		if(empty($passwd)){
			$this->error(L('HANDLE_ERROR'),"",true);
		}
		if(sp_compare_password($pwd,$passwd['user_pass'])){
			session('ADMIN_ID',$admin_id);
			$this->success(L('HANDLE_SUCCESS'),U("Admin/Index/index"),true);
		}else{
			$this->error(L('HANDLE_ERROR'),"",true);
		}

	}

}